package person.zjh.kaoyansharehub.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import person.zjh.kaoyansharehub.dto.PageCommentDTO;
import person.zjh.kaoyansharehub.dto.PageFavoriteDTO;
import person.zjh.kaoyansharehub.dto.SaveFavoriteDTO;
import person.zjh.kaoyansharehub.result.PageResult;
import person.zjh.kaoyansharehub.result.Result;
import person.zjh.kaoyansharehub.service.FavoriteService;

/**
 * @description: TODO
 * @author 郑佳豪
 * @date 2025/2/21 12:54
 * @version 1.0
 */
@RestController
@RequestMapping("/front/favorite")
@Slf4j
@RequiredArgsConstructor
public class FavoriteController {
    private final FavoriteService favoriteService;

    @PostMapping("/saveFavorite")
    public Result saveFavorite(@RequestBody SaveFavoriteDTO requestParam){
        log.info("添加收藏资料的参数:{}",requestParam);
        return favoriteService.saveFavorite(requestParam);
    }

    @PostMapping("/getFavoriteByUserId")
    public PageResult getFavoriteByUserId(@RequestBody PageFavoriteDTO requestParam){
        log.info("查询用户收藏列表参数:{}",requestParam);
        return favoriteService.getFavoriteByUserId(requestParam);
    }

    @GetMapping("/getFavoriteCount/{userId}")
    public Result getFavoriteCount(@PathVariable("userId") Long userId){
        log.info("用户id：{}",userId);
        return favoriteService.getFavoriteCount(userId);
    }
}
